#include <rtthread.h>
#include <rtdevice.h>

#include "beep.h"

typedef struct
{
    int num;
    int time;
} beep;


void ist_beep_init(void)
{
    rt_pin_mode(BEEP_IO, PIN_MODE_OUTPUT);
    rt_pin_write(BEEP_IO, 1);
}

void ist_beep_on(uint8_t num, uint16_t mdelay_time)
{
    uint8_t i = 0;
    if(num == 1)
    {
        rt_pin_write(BEEP_IO, 0);
        rt_thread_mdelay(mdelay_time);
        rt_pin_write(BEEP_IO, 1);
        return ;
    }
    for(i=0; i<num; i++)
    {
        rt_pin_write(BEEP_IO, 0);
        rt_thread_mdelay(mdelay_time);
        rt_pin_write(BEEP_IO, 1);
        rt_thread_mdelay(mdelay_time);
    }
}

INIT_COMPONENT_EXPORT(ist_beep_init);
